﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeRobot.DAL
{
    /// <summary>
    /// 创建README文件
    /// </summary>
    public class ReadmeHelper
    {
        /// <summary>
        /// 创建BLL README文件
        /// </summary>
        /// <param name="strPath">路径</param>
        /// <param name="strProjectName">项目命名</param>
        public static void CreateBLLFile(string strPath,string strProjectName)
        {
            try
            {
                string strLine = "# "+ strProjectName + ".BLL\r\n";
                strLine += "\r\n";
                strLine += "业务处理层\r\n";
                strLine += "\r\n";
                strLine += "demo:\r\n";
                strLine += "```\r\n";
                strLine += "\r\n";
                strLine += "UsersModel user = new UsersModel();\r\n";
                strLine += "user.UserName = \"cloudin\";\r\n";
                strLine += "user.UserPassword = \"53344521\";\r\n";
                strLine += "user.NickName = \"云里科技\";\r\n";
                strLine += "user.UserType = 1;\r\n";
                strLine += "\r\n";
                strLine += "UsersBLL.InsertUsers(user);\r\n";
                strLine += "\r\n";
                strLine += "```\r\n";
                strLine += "\r\n";
                strLine += "\r\n";
                strLine += "Ⅰ.引用程序集说明：\r\n";
                strLine += "\r\n";
                strLine += "暂无\r\n";
                strLine += "\r\n";
                strLine += "Ⅱ.引用第三方组件：工具 → NuGet包管理 → 程序包管理控制台\r\n";
                strLine += "\r\n";
                strLine += "暂无\r\n";
                strLine += "\r\n";
                strLine += "Ⅲ.引用项目说明：\r\n";
                strLine += "\r\n";
                strLine += "" + strProjectName + ".DAL //数据处理层\r\n";
                strLine += "" + strProjectName + ".Model //数据实体类\r\n";
                strLine += "\r\n";

                CodeRobot.Utility.TxtFile.CreateReadMeFile(strLine, strPath);
            }
            catch (Exception ex)
            {
                CodeRobot.Utility.LogHelper.Error(typeof(ReadmeHelper), ex, "创建BLL README文件", "CreateBLLFile");
            }
        }

        /// <summary>
        /// 创建DAL README文件
        /// </summary>
        /// <param name="strPath">路径</param>
        /// <param name="strProjectName">项目命名</param>
        public static void CreateDALFile(string strPath, string strProjectName)
        {
            try
            {
                string strLine = "# " + strProjectName + ".DAL\r\n";
                strLine += "\r\n";
                strLine += "数据处理层\r\n";
                strLine += "\r\n";
                strLine += "demo:\r\n";
                strLine += "```\r\n";
                strLine += "\r\n";
                strLine += "/// <summary>\r\n";
                strLine += "/// 新增一条数据\r\n";
                strLine += "/// </summary>\r\n";
                strLine += "/// <param name=\"usersModel\">实体类</param>\r\n";
                strLine += "/// <returns></returns>\r\n";
                strLine += "public static bool InsertUsers(UsersModel usersModel)\r\n";
                strLine += "{\r\n";
                strLine += "	UsersDAL usersDAL = new UsersDAL();\r\n";
                strLine += "\r\n";
                strLine += "	return usersDAL.InsertUsers(usersModel);\r\n";
                strLine += "}\r\n";
                strLine += "\r\n";
                strLine += "```\r\n";
                strLine += "\r\n";
                strLine += "Ⅰ.引用程序集说明：\r\n";
                strLine += "\r\n";
                strLine += "暂无\r\n";
                strLine += "\r\n";
                strLine += "Ⅱ.引用第三方组件：工具 → NuGet包管理 → 程序包管理控制台\r\n";
                strLine += "\r\n";
                strLine += "install-package MySql.Data -pre\r\n";
                strLine += "\r\n";
                strLine += "Ⅲ.引用项目说明：\r\n";
                strLine += "\r\n";
                strLine += "" + strProjectName + ".DBSqlHelper //数据连接\r\n";
                strLine += "" + strProjectName + ".Model //数据实体类\r\n";
                strLine += "" + strProjectName + ".Utility //常用工具封装类\r\n";
                strLine += "\r\n";

                CodeRobot.Utility.TxtFile.CreateReadMeFile(strLine, strPath);
            }
            catch (Exception ex)
            {
                CodeRobot.Utility.LogHelper.Error(typeof(ReadmeHelper), ex, "创建DAL README文件", "CreateDALFile");
            }
        }

        /// <summary>
        /// 创建DBSqlHelper README文件
        /// </summary>
        /// <param name="strPath">路径</param>
        /// <param name="strProjectName">项目命名</param>
        public static void CreateDBSqlHelperFile(string strPath, string strProjectName)
        {
            try
            {
                string strLine = "# " + strProjectName + ".DAL\r\n";
                strLine += "\r\n";
                strLine += "数据连接封装类\r\n";
                strLine += "\r\n";
                strLine += "demo:\r\n";
                strLine += "```\r\n";
                strLine += "\r\n";
                strLine += "private DBMySQLHelper mysqlHelper;\r\n";
                strLine += "\r\n";
                strLine += "```\r\n";
                strLine += "\r\n";
                strLine += "Ⅰ.引用程序集说明：\r\n";
                strLine += "\r\n";
                strLine += "暂无\r\n";
                strLine += "\r\n";
                strLine += "Ⅱ.引用第三方组件：工具 → NuGet包管理 → 程序包管理控制台\r\n";
                strLine += "\r\n";
                strLine += "install-package MySql.Data -pre\r\n";
                strLine += "\r\n";
                strLine += "Ⅲ.引用项目说明：\r\n";
                strLine += "\r\n";
                strLine += "暂无\r\n";
                strLine += "\r\n";

                CodeRobot.Utility.TxtFile.CreateReadMeFile(strLine, strPath);
            }
            catch (Exception ex)
            {
                CodeRobot.Utility.LogHelper.Error(typeof(ReadmeHelper), ex, "创建DBSqlHelper README文件", "CreateDBSqlHelperFile");
            }
        }

        /// <summary>
        /// 创建Model README文件
        /// </summary>
        /// <param name="strPath">路径</param>
        /// <param name="strProjectName">项目命名</param>
        public static void CreateModelFile(string strPath, string strProjectName)
        {
            try
            {
                string strLine = "# " + strProjectName + ".DAL\r\n";
                strLine += "\r\n";
                strLine += "实体数据类\r\n";
                strLine += "\r\n";
                strLine += "demo:\r\n";
                strLine += "```\r\n";
                strLine += "\r\n";
                strLine += "UsersModel user = new UsersModel();\r\n";
                strLine += "\r\n";
                strLine += "user.UserName = \"cloudin\";\r\n";
                strLine += "user.UserPassword = \"53344521\";\r\n";
                strLine += "user.UserType = 1;\r\n";
                strLine += "user.NickName = \"云里科技\";\r\n";
                strLine += "\r\n";
                strLine += "```\r\n";
                strLine += "\r\n";
                strLine += "Ⅰ.引用程序集说明：\r\n";
                strLine += "\r\n";
                strLine += "暂无\r\n";
                strLine += "\r\n";
                strLine += "Ⅱ.引用第三方组件：工具 → NuGet包管理 → 程序包管理控制台\r\n";
                strLine += "\r\n";
                strLine += "暂无\r\n";
                strLine += "\r\n";
                strLine += "Ⅲ.引用项目说明：\r\n";
                strLine += "\r\n";
                strLine += "暂无\r\n";
                strLine += "\r\n";

                CodeRobot.Utility.TxtFile.CreateReadMeFile(strLine, strPath);
            }
            catch (Exception ex)
            {
                CodeRobot.Utility.LogHelper.Error(typeof(ReadmeHelper), ex, "创建Model README文件", "CreateModelFile");
            }
        }

        /// <summary>
        /// 创建Utility README文件
        /// </summary>
        /// <param name="strPath">路径</param>
        /// <param name="strProjectName">项目命名</param>
        public static void CreateUtilityFile(string strPath, string strProjectName)
        {
            try
            {
                string strLine = "# " + strProjectName + ".Utility\r\n";
                strLine += "\r\n";
                strLine += "常用工具封装\r\n";
                strLine += "\r\n";
                strLine += "demo:\r\n";
                strLine += "```\r\n";
                strLine += "\r\n";
                strLine += "" + strProjectName + ".Utility.LogHelper.Error(typeof(UsersDAL), ex, \"新增一条数据，SQL语句：\" + strSql, \"InsertUsers\");\r\n";
                strLine += "特别注意：如果是WinForm程序，必须把log4net.config配置文件拷贝到Debug目录下，否则日志记录不生效\r\n";
                strLine += "\r\n";
                strLine += "```\r\n";
                strLine += "\r\n";
                strLine += "Ⅰ.引用程序集说明：\r\n";
                strLine += "\r\n";
                strLine += "System.Windows.Forms//桌面项目\r\n";
                strLine += "System.Web//web项目\r\n";
                strLine += "\r\n";
                strLine += "Ⅱ.引用第三方组件：工具 → NuGet包管理 → 程序包管理控制台\r\n";
                strLine += "\r\n";
                strLine += "install-package log4net //日志管理\r\n";
                strLine += "\r\n";
                strLine += "Ⅲ.引用项目说明：\r\n";
                strLine += "\r\n";
                strLine += "暂无\r\n";
                strLine += "\r\n";

                CodeRobot.Utility.TxtFile.CreateReadMeFile(strLine, strPath);
            }
            catch (Exception ex)
            {
                CodeRobot.Utility.LogHelper.Error(typeof(ReadmeHelper), ex, "创建Utility README文件", "CreateUtilityFile");
            }
        }


        /// <summary>
        /// 创建MANAGE README文件
        /// </summary>
        /// <param name="strPath">路径</param>
        /// <param name="strProjectName">项目命名</param>
        public static void CreateManageFile(string strPath, string strProjectName)
        {
            try
            {
                string strLine = "# " + strProjectName + ".Manage\r\n";
                strLine += "\r\n";
                strLine += "后台管理系统\r\n";
                strLine += "\r\n";
                strLine += "demo:\r\n";
                strLine += "```\r\n";
                strLine += "\r\n";
                strLine += "暂无\r\n";
                strLine += "\r\n";
                strLine += "```\r\n";
                strLine += "\r\n";
                strLine += "Ⅰ.引用程序集说明：\r\n";
                strLine += "\r\n";
                strLine += "暂无\r\n";
                strLine += "\r\n";
                strLine += "Ⅱ.引用第三方组件：工具 → NuGet包管理 → 程序包管理控制台\r\n";
                strLine += "\r\n";
                strLine += "install-package log4net //日志管理\r\n";
                strLine += "\r\n";
                strLine += "Ⅲ.引用项目说明：\r\n";
                strLine += "\r\n";
                strLine += "" + strProjectName + ".DBSqlHelper //数据连接\r\n";
                strLine += "" + strProjectName + ".Model //数据实体类\r\n";
                strLine += "" + strProjectName + ".Utility //常用工具封装类\r\n";
                strLine += "" + strProjectName + ".BLL //业务逻辑处理类\r\n";
                strLine += "\r\n";

                CodeRobot.Utility.TxtFile.CreateReadMeFile(strLine, strPath);
            }
            catch (Exception ex)
            {
                CodeRobot.Utility.LogHelper.Error(typeof(ReadmeHelper), ex, "创建MANAGE README文件", "CreateManageFile");
            }
        }


    }
}
